//
//  BRAddHostViewController.m
//  ZhuShou
//
//  Created by Dejun Liu on 15/11/23.
//  Copyright © 2015年 jw. All rights reserved.
//

#import "BRAddHostViewController.h"

@interface BRAddHostViewController ()
@property (weak, nonatomic) IBOutlet UITextField *hostName;
@property (weak, nonatomic) IBOutlet UITextField *hostID;

@end

@implementation BRAddHostViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"添加主机";
    [self init_addTapViewEndEdit];
}
- (IBAction)submit:(id)sender {
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic hs_setSafeValue:_hostName.text forKey:@"name"];
    [dic hs_setSafeValue:_hostID.text forKey:@"code"];
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params hs_setSafeValue:@"mainframe" forKey:@"type"];
    [params hs_setSafeValue:@"code" forKey:@"name"];
    [params hs_setSafeValue:dic forKey:@"value"];
    
    [self br_progressHUD:YES];
    [BRServiceCenter BRServiceCenterUPDWithAction:@"insertDevice" CMD:[BRCommand CommandDeviceCRUD] params:params response:^(BRMessageResponseType type, NSInteger retryCount, id responseObj) {
        if (responseObj) {
            [self br_progressHUD:NO];
            BRUDPResponse *response = responseObj;
            if ([response.state isEqualToString:@"0000"]) {
                [self br_AutoDisappearWithText:@"添加主机成功！"];
            }else
            {
                [self br_AutoDisappearWithText:response.stateDesc];
            }
        }
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
